package com.tedu._06weibo.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Slf4j
public class LogAspect {
    @Before("execution(public * com.tedu._06weibo.controller.*.*(..))")
    public void before(JoinPoint point){
        String classNamae = point.getTarget().getClass().getSimpleName();
        String methodName = point.getSignature().getName();
        log.trace(classNamae+"."+methodName+"()执行了");
    }

    @AfterReturning("execution(public * com.tedu._06weibo.controller.*.*(..))")
    public void afterReturning(JoinPoint point){
        String classNamae = point.getTarget().getClass().getSimpleName();
        String methodName = point.getSignature().getName();
        log.trace(classNamae+"."+methodName+"()结束了");
    }
    @AfterThrowing(value ="execution(public * com.tedu._06weibo.controller.*.*(..))",
    throwing = "e")
    public void afterThrowing(Exception e){
        log.error(e.getMessage());
    }



}
